﻿using System;
using System.Windows;
using System.Windows.Controls;
using DALHelper.Business;

namespace ResortManager.Wizard
{
    /// <summary>
    /// Interaction logic for DefaultConfiguration1.xaml
    /// </summary>
    public partial class BRConfig0 : UserControl, IProceedureComponent
    {
        private pgLookup m_pgRoomCatLookup;

        public BRConfig0()
        {
            InitializeComponent();

            m_pgRoomCatLookup = new pgLookup();
            m_pgRoomCatLookup.IsBooking = true;
            m_pgRoomCatLookup.KeepAlive = false;
            frmBookRoom.Navigate(m_pgRoomCatLookup);
            m_pgRoomCatLookup.Width = frmBookRoom.Width;
            m_pgRoomCatLookup.Height = frmBookRoom.Height;
        }

        #region IProceedureComponent Members

        public string KeyText
        {
            get { return "Chọn số khách"; }
        }

        public bool RequestNext()
        {
            int iBookedCount;
            RoomCategory[] arrRoomList = (RoomCategory[])m_pgRoomCatLookup.GetRoomCatList(out iBookedCount);
            if (iBookedCount > 0)
            {
                try
                {
                    App app = (App)App.Current;
                    app.BUSManager.TransDetail.BookRooms(app.CurrentTransactionID, arrRoomList);
                    ParentWizard.WizardCommonData = app.BUSManager.Transaction.QueryTransactionDetail(app.CurrentTransactionID);

                    return true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Không thể đặt phòng thỏa yêu cầu.\r\nVui lòng thử lại sau.\r\n\r\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Hãy nhập số lượng khách cần đăng kí theo yêu cầu!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return false;
        }

        public ProceedureDialog ParentWizard
        {
            get;
            set;
        }

        public void UpdateComponent()
        {

        }

        #endregion
    }
}
